<template>
  <span v-if="!checkAuthCode(resourceCode)">***</span>
  <el-tag v-else-if="!isNullOrUndefined(money) && !Number.isNaN(money)"
          :disable-transitions="true"
          :hit="border"
          :type="elTagType"
          round
          effect="dark">{{ str }}
  </el-tag>
</template>

<script setup>
import {computed} from "vue";
import {checkAuthCode, isNullOrUndefined} from "@/config/common";

const border = true
let elTagType = "info"

const props = defineProps({
  resourceCode: {
    type: String,
    default: null,
  },
  money: {
    type: Number,
    default: null,
  },
  currency: {
    type: String,
    default: "CNY",
  },
  elTagType: {
    type: String,
    default: "info",
  },
})

const str = computed(() => {
  const val = props.money
  if (isNullOrUndefined(val) || Number.isNaN(val)) {
    return ''
  }
  elTagType = props.elTagType
  console.log('elTagType',elTagType)
  let num = parseFloat(val).toLocaleString();
  switch (props.currency) {
    case 'CNY':
      return '￥' + num
    case 'USD':
      return '$' + num
    default:
      return num
  }
})
</script>
